# 示例：csv_loader.py
from langchain_community.document_loaders.csv_loader import CSVLoader

# 加载csv文档
csv_file_path = ("./llm_langchain_data/doc_search.csv")
csv_loader = CSVLoader(file_path=csv_file_path, encoding="UTF-8")
csv_loader_data = csv_loader.load()
for csv_record in csv_loader_data[:2]:
    print(csv_record)


#自定义 csv加载
custom_csv_loader = CSVLoader(
    file_path=csv_file_path,
    encoding="UTF-8",
    csv_args={
        "delimiter": ",",
        "quotechar": '"',
        "fieldnames": ["Name", "Species", "Age", "Habitat"],
    },
)
custom_csv_loader_data = custom_csv_loader.load()
for custom_csv_record in custom_csv_loader_data[:2]:
    print(custom_csv_record)

